<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table {
            width: 600px;
            color: blue;
            text-align: center;
            margin: 0 auto;
        }

        thead {
            background-color: #7FC8ED;
            color: black;
        }

        tbody td {
            border-bottom: 1px solid gray;
        }

        .bg {
            background-color: pink;
        }
    </style>
</head>

<body>
    <table>
        <thead>
            <tr>
                <th>666</th>
                <th>666</th>
                <th>666</th>
                <th>666</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>777</td>
                <td>888</td>
                <td>999</td>
                <td>789</td>
            </tr>
            <tr>
                <td>777</td>
                <td>888</td>
                <td>999</td>
                <td>789</td>
            </tr>
            <tr>
                <td>777</td>
                <td>888</td>
                <td>999</td>
                <td>789</td>
            </tr>
            <tr>
                <td>777</td>
                <td>888</td>
                <td>999</td>
                <td>789</td>
            </tr>
            <tr>
                <td>777</td>
                <td>888</td>
                <td>999</td>
                <td>789</td>
            </tr>
        </tbody>
    </table>
    <script>
        // 2.根据数据创建表格实现隔行变色功能
        var tre = document.querySelector('tbody').querySelectorAll('tr');
        for (i = 0; i < tre.length; i++) {
            tre[i].onmouseover = function () {
                // console.log(33);
                this.className = 'bg';
            }
            tre[i].onmouseout = function () {
                this.className = '';
            }
        }
    </script>

</body>

</html>